package com.ruiyi.adrobot.beans;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.List;

/**
 * Created by tao.zeng on 2017/5/16
 */
@Document
public class TaskDetail {
    @Id
    private String id; // 任务id
    private String taskNo; // 任务编号
    private Integer fun; // 任务
    private String funName;// 任务名
    private Integer totalTime; // 任务总次数
    private Integer finishTime = 0; // 任务完成次数
    private List<String> groupNames; // 組
    private String startTime; // 开始时间
    private String endTime; // 结束时间
    private Boolean repeatTime; // 循环次数
    private String startDate; // 开始日期
    private String endDate; // 结束日期
    private String createDate; // 创建时间
    private Boolean finished = false; // 任务是否完成
    private List<Task> tasks; // 任务列表
    private List<TaskConfig.Flow> flows; // 流程
    private List<String> usedImeis; // 二次登陆使用过的设备
    private Boolean excuted; // 是否已经执行分发线程
    private Integer didType; // IP固定到 1 省 2 市
    private Integer deviceType; // 0 所有设备 1虚拟设备 2真实设备

    public Integer getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(Integer deviceType) {
        this.deviceType = deviceType;
    }

    public Integer getDidType() {
        return didType;
    }

    public void setDidType(Integer didType) {
        this.didType = didType;
    }

    public String getTaskNo() {
        return taskNo;
    }

    public void setTaskNo(String taskNo) {
        this.taskNo = taskNo;
    }

    public List<TaskConfig.Flow> getFlows() {
        return flows;
    }

    public void setFlows(List<TaskConfig.Flow> flows) {
        this.flows = flows;
    }

    public String getFunName() {
        return funName;
    }

    public void setFunName(String funName) {
        this.funName = funName;
    }

    public Boolean getExcuted() {
        return excuted;
    }

    public void setExcuted(Boolean excuted) {
        this.excuted = excuted;
    }

    public static class Task implements Comparable {
        private String flowId; //流程编号
        private Integer num; // 任务编号
        private String excuteSimCode; // 执行该任务设备唯一标识
        private String startTime; // 开始执行任务时间
        private String endTime; // 任务完成时间
        private String vpnHost; // 执行时的IP
        private Boolean success = false; // 该任务是否执行成功
        private Boolean sent = false; // 是否已发送
        private String userName; // vpn用户名
        private String password; // vpn密码
        private String stepNum; // 完成步骤 0代表全部完成
        private Integer errorCode; // 错误码
        private Device device; // 设备信息
        private List<Device.AccountInfo> usedAccountInfo; // 使用过的账户信息
        private Integer stepType3 = -1; // 表记stepType3在第几步
        private List<TaskDynamicInfo> taskDynamicInfo; // 任务中需要的信息
        private Boolean reported = false; // 是否已统计


        public Boolean getReported() {
            return reported;
        }

        public void setReported(Boolean reported) {
            this.reported = reported;
        }

        public static class TaskDynamicInfo {
            private Integer step; // 第几步
            private String viewText; // 内容

            public TaskDynamicInfo() {
            }

            public TaskDynamicInfo(Integer step, String viewText) {
                this.step = step;
                this.viewText = viewText;
            }

            public Integer getStep() {
                return step;
            }

            public void setStep(Integer step) {
                this.step = step;
            }

            public String getViewText() {
                return viewText;
            }

            public void setViewText(String viewText) {
                this.viewText = viewText;
            }
        }

        public Integer getStepType3() {
            return stepType3;
        }

        public void setStepType3(Integer stepType3) {
            this.stepType3 = stepType3;
        }

        public String getFlowId() {
            return flowId;
        }

        public void setFlowId(String flowId) {
            this.flowId = flowId;
        }

        public String getStepNum() {
            return stepNum;
        }

        public void setStepNum(String stepNum) {
            this.stepNum = stepNum;
        }

        public Device getDevice() {
            return device;
        }

        public void setDevice(Device device) {
            this.device = device;
        }

        public List<Device.AccountInfo> getUsedAccountInfo() {
            return usedAccountInfo;
        }

        public void setUsedAccountInfo(List<Device.AccountInfo> usedAccountInfo) {
            this.usedAccountInfo = usedAccountInfo;
        }

        public List<TaskDynamicInfo> getTaskDynamicInfo() {
            return taskDynamicInfo;
        }

        public void setTaskDynamicInfo(List<TaskDynamicInfo> taskDynamicInfo) {
            this.taskDynamicInfo = taskDynamicInfo;
        }

        public Integer getErrorCode() {
            return errorCode;
        }

        public void setErrorCode(Integer errorCode) {
            this.errorCode = errorCode;
        }

        public String getUserName() {
            return userName;
        }

        public void setUserName(String userName) {
            this.userName = userName;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public Task(String flowId, Integer num, String startTime) {
            this.flowId = flowId;
            this.num = num;
            this.startTime = startTime;
        }

        public String getEndTime() {
            return endTime;
        }

        public void setEndTime(String endTime) {
            this.endTime = endTime;
        }

        public Integer getNum() {
            return num;
        }

        public void setNum(Integer num) {
            this.num = num;
        }

        public Boolean getSent() {
            return sent;
        }

        public void setSent(Boolean sent) {
            this.sent = sent;
        }

        public String getStartTime() {
            return startTime;
        }

        public void setStartTime(String startTime) {
            this.startTime = startTime;
        }

        public String getExcuteSimCode() {
            return excuteSimCode;
        }

        public void setExcuteSimCode(String excuteSimCode) {
            this.excuteSimCode = excuteSimCode;
        }

        public String getVpnHost() {
            return vpnHost;
        }

        public void setVpnHost(String vpnHost) {
            this.vpnHost = vpnHost;
        }

        public Boolean getSuccess() {
            return success;
        }

        public void setSuccess(Boolean success) {
            this.success = success;
        }

        @Override
        public int compareTo(Object o) {
            Task task = (Task) o;
            String startTime = task.getStartTime();
            return this.startTime.compareTo(startTime);
        }
    }

    public TaskDetail(String taskNo, Integer fun, List<String> groupNames, Integer totalTime, String startTime, String endTime, List<Task> tasks, Boolean excuted, List<TaskConfig.Flow> flows, String createDate, Integer didType, Integer deviceType) {
        this.taskNo = taskNo;
        this.fun = fun;
        this.groupNames = groupNames;
        this.totalTime = totalTime;
        this.startTime = startTime;
        this.endTime = endTime;
        this.setTasks(tasks);
        this.excuted = excuted;
        this.flows = flows;
        this.createDate = createDate;
        this.didType = didType;
        this.deviceType = deviceType;
    }

    public List<String> getUsedImeis() {
        return usedImeis;
    }

    public void setUsedImeis(List<String> usedImeis) {
        this.usedImeis = usedImeis;
    }

    public List<String> getGroupNames() {
        return groupNames;
    }

    public void setGroupNames(List<String> groupNames) {
        this.groupNames = groupNames;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public Boolean getRepeatTime() {
        return repeatTime;
    }

    public void setRepeatTime(Boolean repeatTime) {
        this.repeatTime = repeatTime;
    }

    public Integer getFinishTime() {
        return finishTime;
    }

    public Boolean getFinished() {
        return finished;
    }

    public void setFinished(Boolean finished) {
        this.finished = finished;
    }

    public void setFinishTime(Integer finishTime) {
        this.finishTime = finishTime;
    }

    public TaskDetail() {
    }

    public Integer getTotalTime() {
        return totalTime;
    }

    public void setTotalTime(Integer totalTime) {
        this.totalTime = totalTime;
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getFun() {
        return fun;
    }

    public void setFun(Integer fun) {
        this.fun = fun;
    }

    public String getCreateDate() {
        return createDate;
    }

    public void setCreateDate(String createDate) {
        this.createDate = createDate;
    }

    public List<Task> getTasks() {
        return tasks;
    }

    public void setTasks(List<Task> tasks) {
        this.tasks = tasks;
    }

}
